<template>
  <div class="">
    <!-- 我的收藏 -->
    <van-nav-bar title="收藏列表" left-arrow @click-left="$router.go(-1)" />

    <!-- 收藏列表 -->
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <LookForHousingLtem v-for="item in list" :key="item.id" :info="item" />
    </van-list>
  </div>
</template>

<script>
import { getArticlesCollect } from '@/api/lookfor'
export default {
  name: 'MyCollection',
  props: {},
  components: {},
  data () {
    return {
      // 渲染的数据
      list: [],
      page: 1,
      loading: false,
      finished: false
    }
  },
  computed: {},
  watch: {},
  methods: {
    async onLoad () {
      const { body } = await getArticlesCollect()
      console.log(body)
      this.list = [...this.list, ...body]
      console.log(this.list)

      // 获取数据成功以后将Loading修改为false，以便于下次加载获取数据
      this.loading = false

      // // 请求完后让当前页面自增
      // this.page++

      // if (this.page > data.data.pageTotal || !data.data.rows.length) {
      //   // 如果当前页大于总页数时，将finished变量改为true，不再触发Load事件
      //   this.finished = true
      // }
    }
  }
}
</script>
<style lang="less" scoped>
.van-nav-bar {
  background-color: #1cb676;
}
::v-deep .van-nav-bar .van-icon {
  color: #fff;
}
::v-deep .van-nav-bar__title {
  color: #fff;
}
.collect-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>
